package zhaomh.catgirl.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import zhaomh.catgirl.zTools;
import zhaomh.catgirl.zConfig;

import java.util.ArrayList;
import java.util.List;

public class MainCommand implements CommandExecutor, TabExecutor  {
    zTools t = new zTools("&d[Z-ねこむすめ]", null);

    public void helpCommand() {
        List<String> list = zConfig.getLanguageList("command.catgirl.help");
        for (String s : list) {
            t.sendM(s);
        }
    }
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        t.setPlayer((Player) sender);

        if (args.length == 0) {

            helpCommand();
        }else if (args.length == 1) {
            if (args[0].equals("help")) {

                helpCommand();
            } else if (args[0].equals("reload")) {
                zConfig.reloadConfig();

                t.sendM2(zConfig.getLanguage("command.catgirl.reload"));
            } else {
                t.sendM2(zConfig.getLanguage("command.no"));
            }
        }


        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {

        List<String> l = new ArrayList<>();

        if (args.length == 1) {
            l.add("help");
            l.add("reload");
        }

        return l;
    }
}